package com.example.musicproject_b.Controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.example.common.b_pojo.Musiccomment;
import com.example.common.dto.Musiccommondto;
import com.example.common.utils.Resultb;
import com.example.service.MusicCommentservice;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/B_admin/comment")
public class BCommentController {

    @Autowired
    private MusicCommentservice musicCommentservice;

    /**
     * @return
     * @param @param null
     * @author znk
     * @date 2024/10/8 14:52
     * 评论列表(不包含逻辑删除)（一级二级评论）(文章名称，作者名称，父评论id，几级评论)
     * 评论名称查询，评论id查询
     */
    @RequestMapping("/list")
    public Resultb list(int pageNum, int pageSize , String content , Long id){
        List<Musiccommondto> page=musicCommentservice.selectAllComment(pageNum,pageSize,content,id);
        return Resultb.success(page);
    }




    /**
     * @return
     * @param @param null
     * @author znk
     * @date 2024/10/8 15:00
     * 根据id删除评论（多选删除）
     */
    @PostMapping("/delete")
    public Resultb delete(@RequestBody List<Long> ids){
        boolean isde=musicCommentservice.deleteCommentsByIds(ids);
        if (!isde){
            return Resultb.error("删除失败");
        }
        return Resultb.success();
    }



}
